//订单时长
var orderTimeChart = echarts.init(document.getElementById('orderTime'));
orderTimeChart.setOption({
    title: {
        left: 'center',
        top: 'top',
        text: '订单时长范围情况',
        textStyle: {
            color: '#fff',
            textShadowBlur: 3,
            textShadowOffsetY: 3,
        }
    },
    tooltip: {
        trigger: 'item',
        formatter: "{b} : <br />{c} ({d}%)"
    },
    series: [
        {
            name:'订单时长范围',
            type: 'pie',
            radius : [30, 110],
            center: ['50%', '63%'],
            data: [
                {
                    value: [],
                    name: []
                }
            ],
            roseType: 'area',
            label: {
                normal: {
                    textStyle: {
                        color: '#fff'
                    }
                }
            },
            labelLine: {
                normal: {
                    lineStyle: {
                        color: '#fff'
                    },
                    smooth: 0,
                    length: 0.8,
                    length2: 20
                }
            },
            itemStyle: {},

            animationType: 'scale',
            animationEasing: 'elasticOut',
            animationDelay: function (idx) {
                return Math.random() * 200;
            }
        }
    ]
});
orderTimeChart.showLoading();
$.ajax({
    type: "POST",
    async: true,
    url: "OrderTimeServlet",
    data: {},
    dataType: "json",
    success: function (resultOfOrderTime) {
        if (resultOfOrderTime) {
            orderTimeChart.hideLoading();
            orderTimeChart.setOption({
                series: [
                    {
                        data: [
                            { value: resultOfOrderTime[0].typeCount, name: resultOfOrderTime[0].type},
                            { value: resultOfOrderTime[1].typeCount, name: resultOfOrderTime[1].type},
                            { value: resultOfOrderTime[2].typeCount, name: resultOfOrderTime[2].type},
                            { value: resultOfOrderTime[3].typeCount, name: resultOfOrderTime[3].type},
                            { value: resultOfOrderTime[4].typeCount, name: resultOfOrderTime[4].type},
                            { value: resultOfOrderTime[5].typeCount, name: resultOfOrderTime[5].type},
                        ]
                    }
                ]
            })
        }
    },
    error: function (errorMsg) {
        alert("ERROR!!!!");
        orderTimeChart.hideLoading();
    }
})